import type { IGetExchangeRecordParams, IGetScoreDetailParams, IOrderData, IPageData, IScoreDetail } from './types'
import { http } from '@/utils/http/axios'

/**
 * 积分商城兑换的订单查询
  GET /h5/user/orderPage
  接口ID：217579414
  接口地址：https://app.apifox.com/link/project/5160540/apis/api-217579414
 */
export function getExchangeRecord(params?: IGetExchangeRecordParams) {
  return http.request<IPageData<IOrderData>>({
    url: `/h5/user/orderPage`,
    method: 'get',
    params,
  })
}

/**
 * 获取积分来源/消费接口
  GET /h5/user/scorePage
  接口ID：217853489
  接口地址：https://app.apifox.com/link/project/5160540/apis/api-217853489
 */
export function getScoreDetail(params?: IGetScoreDetailParams) {
  return http.request<IPageData<IScoreDetail>>({
    url: `/h5/user/scorePage`,
    method: 'get',
    params,
  })
}

/**
 * 根据code查询订单
  GET /h5/user/order/getOne/{code}
  接口ID：219006440
  接口地址：https://app.apifox.com/link/project/5160540/apis/api-219006440
 */
export function getOrderDataByCode(code: string) {
  return http.request<IOrderData>({
    url: `/h5/user/order/getOne/${code}`,
    method: 'get',
  })
}

/**
 * 积分商城购买后核销
  PUT /h5/user/goods/order
  接口ID：217573445
  接口地址：https://app.apifox.com/link/project/5160540/apis/api-217573445
 */
export function writeOffOrder(code: string) {
  return http.request({
    url: `/h5/user/goods/order`,
    method: 'PUT',
    data: {
      code,
    },
  })
}
